package com.drdj.exam;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

	private ListView mListView;
	private ArrayAdapter<String> mAdapter;

	private ArrayList<Class<?>> mActivityList;
	private ArrayList<String> mItemsList;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		mItemsList = new ArrayList<String>();
		mActivityList = new ArrayList<Class<?>>();

		mItemsList.add("Activity and Data");
		mActivityList.add(ActivityAndData.class);
		
		mItemsList.add("Call and Open Dialer");
		mActivityList.add(CallAndDialer.class);

		mItemsList.add("Vibration");
		mActivityList.add(Vibrate.class);

		mItemsList.add("SlidingDrawer Test");
		mActivityList.add(SlidingDrawerTest.class);
		
		mItemsList.add("Message List");
		mActivityList.add(MessageList.class);

		mItemsList.add("TCP Socket");
		mActivityList.add(TcpClient.class);

		mItemsList.add("Connect Mysql");
		mActivityList.add(ConnectMysql.class);
		
		mItemsList.add("Flip Views");
		mActivityList.add(FlipViews.class);
		
		mItemsList.add("Test Activity");
		mActivityList.add(TestActivity.class);
		
		setList();

	}

	private void setList() {
		mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItemsList);
		mListView = getListView();
		mListView.setAdapter(mAdapter);

		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				startActivity(new Intent(MainActivity.this, mActivityList.get(position)));
			}
		});
	}
}